<template>
  <div>
    <el-form :model="from" label-width="100px" class="demo-ruleForm">
      <el-form-item label="字典编号">
        <el-input v-model="form.DicNo"></el-input>
      </el-form-item>
      <el-form-item label="字典名称">
        <el-input v-model="form.DicName"></el-input>
      </el-form-item>
      <el-form-item label="父级ID">
        <el-input-number
          v-model="form.Pid"
          :min="0"
          :max="1000"
          label="描述文字"
        ></el-input-number>
      </el-form-item>
      <el-form-item label="排序号">
        <el-input-number
          v-model="form.OrderNo"
          :min="0"
          :max="1000"
          label="描述文字"
        ></el-input-number>
      </el-form-item>
      <el-form-item label="是否启用">
        <el-select v-model="form.Enable">
          <el-option label="启用" :value="1"></el-option>
          <el-option label="禁用" :value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="Sql语句">
        <el-input v-model="form.DbSql" placeholder="select [字段值] as 'key',[字段值] as 'value' from 表名"></el-input>
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="form.Remark"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">添加</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        OrderNo: 0,
        Pid: 0,
        Enable: 1,
      },
    };
  },
  methods: {
    submitForm() {
      this.axios
        .post("http://localhost:5255/api/Ditonary/AddDitonary", this.form)
        .then((res) => {
          if (res.data.Success) {
            this.$message.success(res.data.ErrorInfo);
            this.$emit("CloseDicAdd");
          } else {
            this.$message.error(res.data.ErrorInfo);
          }
        });
    },
  },
};
</script>

<style>
</style>